<?php
class News {
	public $db = '';
	public $select = "";
	public $sql = "";
	function __construct() {
		$this->db = Zend_Registry::get ( 'db' );
		$profiler = $this->db->getProfiler ();
	}
	
	public function fetchRow() {
		$this->sql = $this->select->__toString ();
		$result = $this->db->fetchAll ( $this->sql );
		return $result;
	}
	public function makeSql($page = 0,$limit = 0,$news_zhuangtai = 2,$section_id = '0') {
		$this->select = $this->db->select ();
		$this->select->from ( array ('n' => 'bc_news' ), array ('id', 'news_title', 'news_view' ) );
		$this->select->joinLeft ( array ('l' => 'bc_lanmu' ), 'n.column_id = l.id', array ('column_name' ) );
		$this->select->joinLeft ( array ('k' => 'bc_keshi' ), 'n.section_id = k.id', array ('kename' ) );
		$this->select->joinLeft ( array ('u' => 'dnt_users' ), 'n.news_uid = u.uid', array ('username' ) );
		$this->select->where ( 'news_zhuangtai = ?', $news_zhuangtai );
		if ($section_id != 0) {
			$this->select->where ( 'section_id = ?', $section_id );
		}
		$this->select->limitPage ( $page, $limit );
		$this->select->order ( "news_uptime desc" );
	}
}
?>